package cn.edu.scau.cmi.yanghaorui.hibernate.dao;



import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import cn.edu.scau.cmi.yanghaorui.singleton.President;


public class BaseHibernateDAO {
	public static Session session;
	public static Session getSession() {
		if(session==null) {
			Configuration cfg = new Configuration();
			cfg.configure("cn/edu/scau/cmi/yanghaorui/hibernate/hibernate.cfg.xml");
			SessionFactory sf = cfg.buildSessionFactory(); // 加载配置文件去构建Session工厂
		    session = sf.openSession();
		}
			
		
		return session;
	}
	
	
}
